<?php
require('config.php');

		$shop_id=$_REQUEST['shop_id'];
		$sql="select * from `".$oto."_shops_cats` where catFlag=1 and shopId='{$shop_id}'";
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$shop_cat[]=$row;//将取得的所有数据赋值给person_info数组
		}
		if(!isset($shop_cat))
		{
			echo '[]';
		}
		else
		{
			$t=0;
			for($i=0;$i<count($shop_cat);$i++)
			{
				if($shop_cat[$i]['parentId']==0)
				{
					$data[$t]['catId']=$shop_cat[$i]['catId'];
					$data[$t]['catName']=$shop_cat[$i]['catName'];
					$t++;
				}
			}
			for($j=0;$j<$t;$j++)
			{
				$t2=0;
				for($i=0;$i<count($shop_cat);$i++)
				{
					if($shop_cat[$i]['parentId']==$data[$j]['catId'])
					{
						$data[$j]['erji'][$t2]['catId']=$shop_cat[$i]['catId'];
						$data[$j]['erji'][$t2]['catName']=$shop_cat[$i]['catName'];
						$t2++;
					}
				}
				if($t2==0) $data[$j]['erji']=[];
			}
		}
		echo json_encode($data);
?>